package com.itnoob.controller;

import com.itnoob.service.OrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhoujun
 * @date 2025/3/20 20:48
 */

@RestController
public class OrderController {

    private Logger logger = LoggerFactory.getLogger(getClass());
    @Autowired
    private OrderService orderService;

    /**
     * localhost:8080/changeStatus?orderId=1&orderStatus=PAID
     * @param orderId
     * @param orderStatus
     * @return
     */
    @PostMapping("/changeStatus")
    public String changeOrderStatus(@RequestParam("orderId") String orderId,
                                    @RequestParam("orderStatus") String orderStatus){
        logger.info(" [changeOrderStatus] [收到前端的请求,订单为 ({})],订单状态为({})",orderId,orderStatus );
        //调用订单服务类方法,改变订单状态
        orderService.changeOrderStatus(orderId,orderStatus);
        //返回成功
        return "success";
    }
}
